package com.hhs.storage.controller;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.hhs.storage.bean.InputParam;
import com.hhs.storage.bean.Result;
import com.hhs.storage.bean.YymSmsTemplate;
import com.hhs.storage.service.YymSmsTemplateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yuanjun
 * @since 2020-08-16
 */
@RestController
@RequestMapping("/app/yymsmstemplate")
@Slf4j
public class AppYymSmsTemplateController {
    @Resource
    YymSmsTemplateService yymSmsTemplateService;
    @RequestMapping(value = "getAll")
    public Map<String, Object> getAll(String userid) {
        log.info("查询用户意见信息");
        EntityWrapper ew = new EntityWrapper<YymSmsTemplate>();
        ew.eq("user_id_",userid);
        List<YymSmsTemplate> result = yymSmsTemplateService.selectList(ew);
        return Result.sucJsonResp(result);
    }

    @RequestMapping(value = "savetemplate")
    public Map<String, Object> saveinf(YymSmsTemplate yjb,String userid) {
        log.info("---add---");
        yjb.setUserId(userid);
        yymSmsTemplateService.insert(yjb);
        return Result.sucJsonResp("保存成功！");
    }

    @RequestMapping(value = "delete")
    public Map<String, Object> dele(String id) {
        log.info("---delete---");
        yymSmsTemplateService.deleteById(id);
        return Result.sucJsonResp("删除成功！");
    }
}

